﻿@model SMECustomerWebsite.Models.ViewModels.SalePerformance.DepositViewModel
@Html.Action("SubMenuKpi", "System")
<div class="row">
    <div class="col-md-12">
        <div class="x_panel">
            <div class="x_title">
                @if (!string.IsNullOrEmpty(Model.DaoInfo.Branch))
                {
                    <h2>KPI OF @Model.DaoInfo.Branch </h2>
                }
                else
                {
                    <h2>@SMECustomerWebsite.Core.Resources.Resource.NotChooseMsboSalePerformance</h2>
                }

                <ul class="nav navbar-right panel_toolbox">
                    @Html.Action("BusinessDateInfo", "System", new { name = "TBL_KPI_MSBO_RAW" })
                    <li>
                        <a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                    </li>
                </ul>
                <div class="clearfix"></div>
            </div>
            <div class="x_content">
                <div class="row">

                    <table id="kpi-msbo-raw" class="table table-bordered table-striped jambo_table custom_table" style="width:100% !important">
                        <thead class="headings">
                            <tr>
                                <th class="column-title" rowspan="2">DAO</th>
                                <th class="column-title" rowspan="2">@SMECustomerWebsite.Core.Resources.Resource.MSBONameHeader</th>
                                <th class="column-title" colspan="3">DƯ NỢ BÌNH QUÂN (TRIỆU VND)</th>
                                <th class="column-title" colspan="3">HUY ĐỘNG BÌNH QUÂN (TRIỆU VND)</th>
                                <th class="column-title" colspan="3">NỢ XẤU PHÁT SINH MỚI (%)</th>
                                <th class="column-title" colspan="3">DƯ NỢ TÍN CHẤP BÌNH QUÂN (TRIỆU VND)</th>
                                <th class="column-title" colspan="3">KHÁCH HÀNG HOẠT ĐỘNG TĂNG THÊM (SỐ LƯỢNG)</th>
                                <th class="column-title" colspan="3">THẺ HOẠT ĐỘNG MỚI (SỐ LƯỢNG)</th>
                                <th class="column-title" rowspan="2">KPI tạm tính</th>
                            </tr>
                            <tr>
                                <th class="column-title">KẾ HOẠCH</th>
                                <th class="column-title">THỰC HIỆN</th>
                                <th class="column-title">ĐIỂM</th>
                                <th class="column-title">KẾ HOẠCH</th>
                                <th class="column-title">THỰC HIỆN</th>
                                <th class="column-title">ĐIỂM</th>
                                <th class="column-title">KẾ HOẠCH</th>
                                <th class="column-title">THỰC HIỆN</th>
                                <th class="column-title">ĐIỂM</th>
                                <th class="column-title">KẾ HOẠCH</th>
                                <th class="column-title">THỰC HIỆN</th>
                                <th class="column-title">ĐIỂM</th>
                                <th class="column-title">KẾ HOẠCH</th>
                                <th class="column-title">THỰC HIỆN</th>
                                <th class="column-title">ĐIỂM</th>
                                <th class="column-title">KẾ HOẠCH</th>
                                <th class="column-title">THỰC HIỆN</th>
                                <th class="column-title">ĐIỂM</th>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
@section scripts
{
    <script src="~/Scripts/tableeditable/dataTables.rowsGroup.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $.ajax({
                url: '/MSBO/ListMSBOName',
                type: "POST",
                data: { data: 1 },
                success: function (data_response) {
                    $("#sp-deposit-msbo-dropdown").select2({
                        placeholder: "Select MSBO",
                        data: data_response
                    });
                    $("#sp-deposit-msbo-dropdown").val("@Model.Dao").trigger("change");
                    $("#sp-deposit-msbo-dropdown").on("change", function (e) {
                        msboselected = $("#sp-deposit-msbo-dropdown").val();
                        var link = "@Url.Action("KPIs", "SalePerformance", new { dao=-1})";
                        link = link.replace("-1", msboselected);
                        window.location.replace(link);
                    });
                }
            });
            var table = $('#kpi-msbo-raw').DataTable({
                "order": [[0, 'asc']],
                "bServerSide": true,
                "bProcessing": true,
                "responsive": true,
                "bAutoWidth": false,
                "aLengthMenu": [10, 30, 50, 100],
                "pageLength": 10,
                //"bProcessing": true,
                "sAjaxSource": '@Url.Action("KpiMsboBranchData", "SalePerformance")',
                "fnServerData": function (sSource, aoData, fnCallback) {
                    $.ajax({
                        "dataType": 'json',
                        "type": "POST",
                        "url": sSource,
                        "data": aoData,
                        "success": fnCallback
                    });
                },
                "aoColumns": [
                            { "sName": "CIF", "bSortable": false },
                            { "sName": "NAME", "bSortable": false },
                            { "sName": "DATE OPEN", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false },
                            { "sName": "DATE OPEN", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false },
                            { "sName": "DATE OPEN", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false },
                            { "sName": "DATE OPEN", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false },
                            { "sName": "DATE OPEN", "className": 'column-title', "bSortable": false },
                            { "sName": "DATE OPEN", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false },
                            { "sName": "DATE OPEN", "className": 'column-title', "bSortable": false },
                            { "sName": "DATE OPEN", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false },
                            { "sName": "VPB INDUSTRY", "className": 'column-title', "bSortable": false }],
                "aoColumnDefs": [{
                    "aTargets": [1],
                    "mRender": function (data, type, full) {
                        return '<a href="/SalePerformance/Kpis?dao=' + full[0] + '" style="color:red;">' + data + ' <i class="fa fa-book"></i></a>';
                    }
                }, {
                    "aTargets": [3],
                    "mRender": function (data, type, full) {
                        return '<a href="/SalePerformance/KPIDNBQ?dao=' + full[0] + '" style="color:red;">' + data + ' <i class="fa fa-file"></i></a>';
                    }
                }, {
                    "aTargets": [6],
                    "mRender": function (data, type, full) {
                        return '<a href="/SalePerformance/KPIHDBQ?dao=' + full[0] + '" style="color:red;">' + data + ' <i class="fa fa-file"></i></a>';
                    }
                }, {
                    "aTargets": [9],
                    "mRender": function (data, type, full) {
                        return '<a href="/SalePerformance/KPIBadDebt?dao=' + full[0] + '" style="color:red;">' + data + ' <i class="fa fa-file"></i></a>';
                    }
                }, {
                    "aTargets": [12],
                    "mRender": function (data, type, full) {
                        return '<a href="/SalePerformance/KPIDNTCBQ?dao=' + full[0] + '" style="color:red;">' + data + ' <i class="fa fa-file"></i></a>';
                    }
                }, {
                    "aTargets": [15],
                    "mRender": function (data, type, full) {
                        return '<a href="/SalePerformance/KPIKHHD?dao=' + full[0] + '" style="color:red;">' + data + ' <i class="fa fa-file"></i></a>';
                    }
                }, {
                    "aTargets": [18],
                    "mRender": function (data, type, full) {
                        return '<a href="/SalePerformance/KPICard?dao=' + full[0] + '" style="color:red;">' + data + ' <i class="fa fa-file"></i></a>';
                    }
                }],
                "drawCallback": function (settings) {
                    $('table.custom_table th').removeClass().addClass('column-title');
                }
            });

        });
    </script>
}
